<extend name="Public:mainbase" />
<block name="content">
<script language="javascript" src="__PUBLIC__/js/member.js?{:time()}"></script>  
<!--  内容列表   -->
<form name="form2" method="post">
<table width="98%" class="table table-bordered  table-hover table-condensed "  align="center">
<tr bgcolor="#E7E7E7" >
	<td height="28" colspan="11" background="__PUBLIC__/images/tbg.gif" style="padding-left:10px;">
	◆ 职位列表 &nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-xs btn-warning" data-toggle="modal" data-target=".newjobbox">添加职位</button>
	</td>
</tr>
<tr align="center" bgcolor="#FBFCE2" height="25">
	<td width="6%">ID</td>
	<td width="4%">选择</td>
	<td width="28%">名称</td>
	<td width="10%">排序</td>
	<td width="10%">状态</td>
	<td width="10%">操作</td>
</tr>
<foreach name="jobList" item="val">
<tr align='center' bgcolor="#FFFFFF" height="26">
	<td nowrap>{$val.jid}</td>
	<td>
		<input name="jid" type="checkbox" value="{$val.jid}" class="np" />
	</td>
	<td>{$val.name}</td>
	<td>{$val.sort}</td>
	<td><eq name="val.status" value="1">启用<else />不启用</eq></td>
	<td>
		<a href="javascript:;" data-jid='{$val.jid}' class='editjob'>修改</a>
		|
		<a href="javascript:;" data-jid='{$val.jid}' class='deljob'>删除</a>
	</td>
</tr>
</foreach>
<tr bgcolor="#ffffff">
<td height="36" colspan="11">
	&nbsp;
	<a href="javascript:selAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-ok'></i> 全选</a>
	<a href="javascript:noSelAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-remove'></i> 取消</a>
	<!-- <a href="javascript:checkArc(0)" class="btn btn-xs btn-info">&nbsp;审核&nbsp;</a> -->
	<a href="javascript:;" id="deljoball" class="btn btn-xs btn-info"><i class="glyphicon glyphicon-trash"></i> 删除</a>
</td>
</tr>
</form>
<tr align="right" bgcolor="#F9FCEF">
	<td height="36" colspan="11" align="center">
		<div page='class'>{$showpage}</div>
	</td>
</tr>
</table>

<!--  搜索表单  -->
<form name='form3' action='{:U('Admin/System/job')}' method='get'>
<input type='hidden' name='dopost' value='listArchives' />
<table width='98%'  class='table' align="center" style="margin-top:8px">
  <tr bgcolor='#EEF4EA'>
    <td background='__PUBLIC__/images/wbg.gif' align='center'>
      <table border='0' cellpadding='0' cellspacing='0' height="32">
        <td nowrap>职位名称：</td>
        <td width='130'>
          	<input type='text' name='name' value='' style='width:120px' />
        </td>
       <td>
          <input name="imageField" type="image" src="__PUBLIC__/images/button_search.gif" width="60" height="22" border="0" class="np" />
       </td>
      </tr>
     </table>
   </td>
  </tr>
</table>
</form>


<!-- 添加职位弹窗 -->
<div class="modal fade newjobbox" tabindex="-1" role="dialog" aria-labelledby="add_user_jump" id='newjobbox'>
  <div class="modal-dialog modal-sm" style="width:40%">
  		
    <div class="modal-content">
		<div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">添加职位信息</h4>
	    </div>
		<form action="" method="POST" class="form-horizontal" style="padding:15px 0">
		<div class="form-group">
			<label for="username" class="col-sm-2 control-label">职位名称</label>
			<div class="col-sm-5">
				<input name="name" type="text" placeholder="请输入职位名称" value="" class="form-control" value="">
			</div>
		</div>

        <div class="form-group">
	        <label for="password" class="col-sm-2 control-label">状态</label>
	        <div class="col-sm-5">
        		<label><input type="radio" name="status" value="1" checked="checked" /> 启用</label>
	        	<label><input type="radio" name="status" value="0" /> 不启用</label>
			</div>
        </div>

		<div class="form-group">
			<label for="realname" class="col-sm-2 control-label">排序</label>
			<div class="col-sm-5">
				<input name="sort" type="text" placeholder="排序" value="0" class="form-control">
			</div>
		</div>

		<div class="add-error-message error item"></div>

		<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="button" class="btn btn-success" id="newjobBtn">确定添加</button>
		      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		      <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
		    </div>
		  </div>
		</form>
    </div>
  </div>
</div>


<!-- 添加用户弹窗 -->
<div class="modal fade editjobbox" tabindex="-1" role="dialog" aria-labelledby="edit_user_jump" id='editjobbox'>
  <div class="modal-dialog modal-sm" style="width:40%">
  		
    <div class="modal-content">
		<div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myModalLabel">修改该职位信息</h4>
	    </div>
		<form action="" method="POST" class="form-horizontal" style="padding:15px 0">
		<div class="form-group">
			<label for="username" class="col-sm-2 control-label">职位名称</label>
			<div class="col-sm-5">
				<input name="name" type="text" placeholder="请输入职位名称" value="" class="form-control" value="">
			</div>
		</div>

        <div class="form-group">
	        <label for="password" class="col-sm-2 control-label">状态</label>
	        <div class="col-sm-5">
        		<label><input type="radio" name="status" id="status_1" value="1" /> 启用</label>
	        	<label><input type="radio" name="status" id="status_0" value="0" /> 不启用</label>
			</div>
        </div>

		<div class="form-group">
			<label for="realname" class="col-sm-2 control-label">排序</label>
			<div class="col-sm-5">
				<input name="sort" type="text" placeholder="排序" value="0" class="form-control">
			</div>
		</div>

		<div class="add-error-message error item"></div>

		<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <input type="hidden" name="jid" value="0" />
		      <button type="submit" class="btn btn-success" id="editjobBtn">确定修改</button>
		      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		      <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
		    </div>
		  </div>
		</form>
    </div>
  </div>
</div>



<script type="text/javascript">
	$('.deljob').click(function(){
		if(confirm('是否确定删除此职位？')){
			var obj=this;
			$.get('{:U("ajaxDelJob")}?jid='+$(obj).data('jid'),function(data){
				if(data.status == 1){
					$(obj).parents('tr').remove();
				}
			})
		}
	})

	$('#deljoball').click(function(){
		if(confirm('是否确定删除？')){
			var id = $('[name=jid]:checked').map(function(){
				return $(this).val();
			}).get().join();

			$.post('{:U("ajaxDelJob")}', {'jid': id},function(data){
				if(data.status == 1){
					$('[name=jid]:checked').parents('tr').remove();
				}
			})
		}
	})

	$('#newjobbox').on('show.bs.modal', function (e) {
  		$('#newjobbox form').get(0).reset();
	})

	$('#newjobBtn').on('click', function () {
  		$.post("{:U('Admin/System/ajaxJobAdd')}", $('.newjobbox form').serialize(), function (data) {
  			if(data.status == 1) {
  				$('#newjobbox').modal('hide');
  				window.location.reload();
  			} else {
  				alert(data.msg);
  			}
  		});
	});

	$('.editjob').click(function(){
		$('#editjobbox form').get(0).reset();
		$.get("{:U('Admin/System/ajaxJobData')}?jid=" + $(this).data('jid'), function(data){
  			if(data.status == 1){
  				$("#editjobbox input[name='name']").val(data.info['name']);
  				$("#editjobbox #status_" + data.info['status']).attr("checked", true); 
  				$("#editjobbox input[name='sort']").val(data.info['sort']);
  				$("#editjobbox input[name='jid']").val(data.info['jid']);
  			}
  		}, 'json')
		$('#editjobbox').modal('show');
	});


	$('#editjobBtn').on('click', function () {
		var data = 
  		$.post("{:U('Admin/System/ajaxJobEdit')}", $('.editjobbox form').serialize(), function (data) {
  			if(data.status == 1) {
  				$('#editjobbox').modal('hide');
  			} else {
  				alert(data.msg);
  			}
  		});
	});

</script>
</block>